package org.come.Jpanel;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;

import org.come.entity.PartJade;
import org.come.mouslisten.StorageJadeMouslisten;
import org.come.until.CutButtonImage;

import com.tool.tcpimg.UIUtils;

 

public class StorageJadeJpanel2 extends JPanel {

    public static PartJade partJade;
    public static JLabel[] labJade = new JLabel[5];
    public static StorageJadeMouslisten[] jadeMouslisten = new StorageJadeMouslisten[5];

    public StorageJadeJpanel2() {
        this.setPreferredSize(new Dimension(291, 171));
        this.setLayout(null);
        this.setBackground(UIUtils.Color_BACK);

        for (int i = 0; i < 5; i++) {

            labJade[i] = new JLabel();
            jadeMouslisten[i] = new StorageJadeMouslisten(i, 2);
            labJade[i].addMouseListener(jadeMouslisten[i]);
            if (i < 3) {
                labJade[i].setBounds(30 + i * 90, 17, 54, 51);
            } else {
                labJade[i].setBounds(75 + (i - 3) * 90, 97, 54, 51);
            }
            this.add(labJade[i]);
        }
    }

    private ImageIcon icon;

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        if (icon == null) {
            icon = CutButtonImage.getImage("inkImg/newbackground/B252.png", -1, -1);
        }
        // 背景
        g.drawImage(icon.getImage(), 0, 0, 291, 171, this);
        g.setColor(Color.white);
        g.setFont(UIUtils.nameFont);
        // 画所拥有玉符的数量
        if (partJade != null) {
            g.drawString(partJade.getJade1() + "", 30, 27);
            g.drawString(partJade.getJade2() + "", 120, 27);
            g.drawString(partJade.getJade3() + "", 210, 27);
            g.drawString(partJade.getJade4() + "", 75, 105);
            g.drawString(partJade.getJade5() + "", 165, 105);
        }

    }

    public static JLabel[] getLabJade() {
        return labJade;
    }

    public static void setLabJade(JLabel[] labJade) {
        StorageJadeJpanel.labJade = labJade;
    }
}
